﻿<html lang="en" window-frame="solid" window-icon="./view/icon/server-favicon.ico"></html>
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="./view/css/index.css">
</head>
<body id="body" role="window-caption">
	<div id="enterbox">
		<!-- 提示  -->
        <div id="messtip" >
			<i id="messtipicon" class="successicon"></i>
			<span class="messtipword">登录 
				<span class="reminderhandle"></span>！
				<span class="errorhandle"></span> 
			</span>
		</div>
		<!-- 提示 -->
		<div class="logobox fl">
			<div class="lg_top">
				<img src="./view/img/logobox-logo.png" alt="">
			</div>
			<div class="lg_bottom">
				版本号&nbsp;1.2.1
			</div>
		</div>
		<div class="loginbox fr">
			<div class="head">
				<div class="setting fr" style="width:60px;">
					<ul>
						<li><button id="minimized" class="minimizedicon loginicon"></button></li>
						<li><button id="closewin" class="closewinicon loginicon"></button></li>
					</ul>
				</div>
			</div>
			<h2 class="_title"></h2>
			<form action="">
				<div class="input_item">
					
					<input type="text" name="username" class="loginicon nameicon" value="请输入正确邮箱">
				</div>
				<div class="input_item">
					<input type="password" name="userpass" id="loginenter" class="loginicon passwordicon" value="">
				</div>
					<span class="alertspan" style="margin-left:70px;color:#ff0000;font-size: 14PX;"> <i></i> 请输入正确的邮箱</span>
				<div class="input_item" style="margin-top:35px">
					<button id="login" class="submit">登录</button>
					<br />
					<button id="register_index" class="register">立即注册</button>
				</div>
			</form>
		</div>
		
	</div>
	<script type="text/tiscript" src="./view/tiscript/index.tis"></script>
	<script type="text/tiscript" src="./view/tiscript/public.tis"></script>
	<script type="text/tiscript">
		moveToScreenCenter(672,517);

		$(#register_index).on("click",function(){

			//	view.register_index()
			view.load("./view/register.html",false);
		});
		$(#messtip).style["display"] = "none"
		$(#enterbox).style["display"] = "block"
		var errors = function(str){
			$(#messtip).style["display"] = "block"
			$(#messtipicon).attributes["class"] = "defeaticon"
			$(.reminderhandle).text = "失败"
			$(.errorhandle).text = "原因:"+str+"!!"
			reminder()
		}
		$(#login).on("click",function(){
			loginfun()
		});
		
		$(#loginenter).on("keyup", function(evt) {
            if(evt.type == Event.KEY_UP && evt.keyCode == Event.VK_RETURN) {
                loginfun()
            }
        });

        function loginfun(){
			var userName = $(input[name=username]).value; 
			var userPass = $(input[name=userpass]).value; 
			var resp = view.login(userName,userPass)
			if(resp.code == 0){
				$(#messtip).style["display"] = "block"
 				view.load("./view/index.html",false);
			}else{
				
				errors(resp.msg)
			}
    	}

		function reminder(){
			var cnt = 2;
			self.timer(1000, function() {
				if(cnt <= 0) {
					//返回false则停止定时器
					$(#messtip).style["display"] = "none"
					return false;
				}
				cnt--;
				return true;
			});
		}

		$(.alertspan).style["display"] = "none"

		var interval = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/

		$(input[name=username]).style["color"] = "#ccc"
		$(input[name=username]).on("focus",function(){
			$(input[name=username]).style["color"] = "#000"
			if($(input[name=username]).value == "请输入正确邮箱"){
				$(input[name=username]).value = ""
			}

		})


		$(input[name=username]).on("blur",function(){
			if($(input[name=username]).value == ""){
				$(input[name=username]).value = "请输入正确邮箱"
				$(input[name=username]).style["color"] = "#ccc"
				$(.alertspan).style["display"] = "none"
			}else{
				var namevalue = $(input[name=username]).value
				var reg = interval.test(namevalue)
				if(!reg){
					$(input[name=username]).style["color"] = "#ff0000"
					$(.alertspan).style["display"] = "block"
				}else{
					$(.alertspan).style["display"] = "none"
				}
			}
		})

	</script>
</body>
</html>


